'''
@Project ：python-study
@File    ：9.7散点图：评分分值与人数.py
@IDE     ：PyCharm
@Author  ：SUNLIN
@Date    ：2025/3/16 10:55:07
'''
import C8处理与分析.pandas_def as pdef
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']  # 使用黑体
plt.rcParams['axes.unicode_minus'] = False  # 解决负号显示问题

# 读取数据
file_path = 'D:\develop\projects\Python Project\python-study\doc\datasource\C8-8.5-数据采集-clean.xlsx'
usecols = ['number_of_people', 'average_score', 'movie_name']
data = pdef.average_votes(file_path, usecols)
print(data)
# 绘制图表
plt.scatter(x=data['average_score'], y=data['number_of_people'])
title = len(data).__str__() + '部电影评分'
plt.title(title)
plt.xlabel('评分分值')
plt.ylabel('评价人数')
plt.grid()
plt.show()

print("================高分热门电影=================")
print(data.sort_values(['average_score', 'number_of_people'], ascending=False).head(5))

# 筛选、排序 -> 结合图表、观察数据
